package com.chixing.day15.INPUT_OUTPUT;

import java.io.*;

public class InputStreamDemo {
    public static void main(String[] args) /*throws Exception */{
        //创建字节读取流
        InputStream is = null;
        try {
            is = new FileInputStream("//Users//jasonmarslyon//CX_Workspace//Java_Workspace//Test//hello.txt");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        byte b[] = new byte[0];
        int len = 0;
        int temp ;
        try {
            b = new byte[is.available()];
        } catch (IOException e) {
            e.printStackTrace();
        }
        //读数据
            try {
                while((temp = is.read(b)) != -1) {
                    b[len++] = (byte)temp;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }finally{
                if(is != null){
                    try {
                        is.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
            String s = new String(b);
            System.out.println(s);


      /*  File f1 = new File("f://workspacetools//CXJY_WORKSPACE//test1//hello.txt");
        InputStream in = new FileInputStream(f1);
        byte b[] = new byte[(int)(f1.length())];
        in.read(b);
        in.close();
        System.out.println(new String(b));*/

    }
}
